package com.xmread.cn.network;

import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import com.liuguang.framework.utils.AppUtils;
import com.liuguang.framework.utils.ToastUtils;

public class RFNetUtil {
    private RFNetUtil() {
    }

    public static boolean isNetworkConnected() {
        if (AppUtils.getApplication() != null) {
            NetworkInfo activeNetworkInfo = ((ConnectivityManager) AppUtils.getApplication().getSystemService("connectivity")).getActiveNetworkInfo();
            if (activeNetworkInfo != null) {
                return activeNetworkInfo.isAvailable();
            }
        }
        return false;
    }

    public static boolean checkWebNet() {
        if (isNetworkConnected()) {
            return true;
        }
        ToastUtils.show("请检查您的网络");
        return false;
    }

    public static boolean isWifiConnected() {
        if (AppUtils.getApplication() != null) {
            NetworkInfo networkInfo = ((ConnectivityManager) AppUtils.getApplication().getSystemService("connectivity")).getNetworkInfo(1);
            if (networkInfo != null) {
                return networkInfo.isAvailable();
            }
        }
        return false;
    }

    public static boolean isMobileConnected() {
        if (AppUtils.getApplication() != null) {
            NetworkInfo networkInfo = ((ConnectivityManager) AppUtils.getApplication().getSystemService("connectivity")).getNetworkInfo(0);
            if (networkInfo != null) {
                return networkInfo.isAvailable();
            }
        }
        return false;
    }

    public static int getConnectedType() {
        if (AppUtils.getApplication() != null) {
            NetworkInfo activeNetworkInfo = ((ConnectivityManager) AppUtils.getApplication().getSystemService("connectivity")).getActiveNetworkInfo();
            if (activeNetworkInfo != null && activeNetworkInfo.isAvailable()) {
                return activeNetworkInfo.getType();
            }
        }
        return -1;
    }

    public static boolean isMobileNO(String str) {
        String str2 = "[1][3578]\\d{9}";
        if (str.equals("")) {
            return false;
        }
        return str.matches(str2);
    }
}
